﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace WpfApplication1.Models
{
    public class PlotSettings
    {
        public ConcurrentDictionary<String, Boolean[]> attributePlotSettings { get; private set; }
        public int columnCount { get; set; }

        public PlotSettings()
        {
            //popluates the hashtable with all the fields in aircraft and a given default plot value
            columnCount = 4;
            attributePlotSettings = new ConcurrentDictionary<String, Boolean[]>();

            //[0] = plot yes/no, [1] = plot desired value yes/no
            Boolean[] defaultPlotSettings = { true, true };

            Type type = typeof(Aircraft); // Get type pointer
            FieldInfo[] fields = type.GetFields(); // Obtain all fields
            foreach (FieldInfo field in fields) // Loop through fields
            {
                if (field != null && field.GetCustomAttribute(typeof(Models.PlotFieldSettings)) == null && !field.Name.Contains("desired"))
                {
                    attributePlotSettings.TryAdd(field.Name, defaultPlotSettings);
                }
            }
        }
    }
}
